export default {
  data() {
    return {
      marginTop: '0px',
      platform: 'android',
      statusBarHeight: '44',
      height: '',
      twoHeight: '',
      right: '',
      boundingTop: '',
      model: '',
      safeAreaInsets: ''
    };
  },
  onLoad() {
    let bounding = uni.getMenuButtonBoundingClientRect();
    // console.log('胶囊', bounding)
    this.height = bounding.height;
    this.right = bounding.right;
    this.boundingTop = bounding.top;
    // 获取系统信息并设置 marginTop
    uni.getSystemInfo({
      success: (res) => {
        console.log(res)
        this.platform = res.osName;
        this.statusBarHeight = res.statusBarHeight;
        this.model = res.model;
        // 增加对iPhone 12及其后续型号的检查
        if (res.model.includes('iPhone') && (
          res.model.includes('X') ||
          res.model.includes('11') ||
          res.model.includes('12') ||
          res.model.includes('13') ||
          res.model.includes('14') ||
          res.model.includes('15')  // 如果后续有iPhone 15等类似型号，也可以继续添加
        )) {
          // console.log("该设备可能是刘海屏设备");
          this.safeAreaInsets = res.safeAreaInsets.top
          this.marginTop = '0px';
          this.twoHeight = this.statusBarHeight * 2;
        } else {
          // console.log("该设备不是刘海屏设备");
          this.marginTop = `-${this.statusBarHeight}px`
          this.twoHeight = this.statusBarHeight * 4;
        }


        // this.marginTop = /android/i.test(this.platform) ? `-${statusBarHeight}px` : '0px';
      },
    });
  },
};